//
//  STProtocolViewController.m
//  赛拓
//
//  Created by 王磊 on 7/31/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STProtocolViewController.h"

@interface STProtocolViewController ()<UIWebViewDelegate>
@property (nonatomic ,strong) UIWebView *webView;
@end

@implementation STProtocolViewController

- (void)initSubviews {
    [super initSubviews];
    UIWebView *webView = [[UIWebView alloc]init];
    
    webView.delegate = self;
    
    webView.scrollView.showsHorizontalScrollIndicator = false;
    
    webView.scrollView.showsVerticalScrollIndicator = false;
    
    webView.scrollView.bounces = false;
    
    self.webView = webView;
    
    webView.suppressesIncrementalRendering = true;
    
    [self.view addSubview:webView];
    
    webView.frame = self.view.bounds;
}

- (void)loadData {
    [super loadData];
    
    @WeakObj(self)
    
    [[STHttpManager getInstance] requestWithUrlString:ST_HTTP_GETPROTOCOL andParams:@{} andStartBlock:^BOOL{
        return true;
    } andSuccessBlock:^(NSString *rescode, NSString *msg, NSString *token, NSString *sysTime, id data, NSString *page) {
        if ([rescode isEqualToString:@"100"]) {
            
            NSString *htmlString = data;
            
            [selfWeak.webView loadData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] MIMEType:@"text/html" textEncodingName:@"UTF8" baseURL:nil];
            
        }else {
            
            [SVProgressHUD showInfoWithStatus:msg];
        }
        
        
    } andFailureBlock:^BOOL{
        
        return true;
    }];
}

@end
